package com.lct.designpattern;

import com.lct.designpattern.builder.Director;
import com.lct.designpattern.builder.Human;
import com.lct.designpattern.builder.SmartManBuilder;
import com.lct.designpattern.factory.SmsFactory;
import com.lct.designpattern.factory.bean.interfaces.Sender;
import com.lct.designpattern.factory.interfaces.Provider;
import com.lct.designpattern.single.Singleton;

public class Main {

    public static void main(String[] args) {
        testFactory();
        testSingle();
        testBuilder();
    }

    /**
     * 工厂模式：对实现了同一接口的一些类进行实例的创建
     */
    private static void testFactory() {
        System.out.println("###############工厂模式################");

        Provider provider = new SmsFactory();
        Sender sender = provider.produce();
        sender.sender();
    }

    private static void testSingle() {
        System.out.println("###############单例模式################");

        System.out.println(Singleton.getInstance());
        System.out.println(Singleton.getInstance());
    }

    private static void testBuilder() {
        System.out.println("###############建造者模式################");

        Director director = new Director();
        Human human = director.createHumanByDirector(new SmartManBuilder());
        System.out.println(human.getHead());
        System.out.println(human.getBody());
        System.out.println(human.getHand());
        System.out.println(human.getFoot());
    }
}
